import { createRouter, createWebHistory } from "vue-router";
import HomeView from "../views/home/HomeView.vue";
import Layout from "@/components/Layout.vue";
import StudentLayout from "@/components/studentStudy/StudentLayout.vue";
export const constantRoutes = [
  {
    name: "login",
    path: "/login",
    component: () => import("@/views/LoginView.vue"),
    meta: {
      title: "登录",
      hidden: true, //代表路由标题在菜单中是否隐藏
    },
  },
  {
    name: "teacherLogin",
    path: "/teacherLogin",
    component: () => import("@/views/LoginViewTeacher.vue"),
    meta: {
      hidden: true,
    },
  },
  {
    name: "register",
    path: "/register",
    component: () => import("@/views/RegisterView.vue"),
    meta: {
      title: "注册",
      hidden: true, //代表路由标题在菜单中是否隐藏
    },
  },
  {
    name: "studentLayout",
    redirect: "/studentLayout/homeStudent",
    path: "/studentLayout",
    component: StudentLayout,
    meta: {
      hidden: true,
    },
    children: [
      {
        name: "homeStudent",
        path: "homeStudent",
        component: () => import("@/views/home/HomeStudent.vue"),
      },
      {
        name: "studentMessage",
        path: "studentMessage",
        component: () => import("@/views/StudentView/StudentMessage.vue"),
      },
      {
        name: "courseStudent",
        path: "courseStudent",
        component: () => import("@/views/StudentView/courseStudent.vue"),
      },
      {
        name: "CourseView",
        path: "CourseView",
        component: () => import("@/views/StudentView/CourseView.vue"),
        props(route: any) {
          return route.query;
        },
      },
      {
        name: "chapter",
        path: "chapter",
        component: () => import("@/views/StudentView/Chapter.vue"),
        props(route: any) {
          return route.query;
        },
      },
      {
        name: "discusion",
        path: "discusion",
        component: () => import("@/views/StudentView/Discusion.vue"),
      },
      {
        name: "discusionMain",
        path: "discusionMain",
        component: () => import("@/views/StudentView/DiscusionMain.vue"),
        props(route: any) {
          return route.query;
        },
      },
      {
        name: "studentPoint",
        path: "studentPoint",
        component: () => import("@/views/StudentView/StudentPoint.vue"),
      },
    ],
  },
  {
    path: "/layout",
    name: "layout",
    component: Layout,
    redirect: "/layout/home",
    meta: {
      title: "首页",
      icon: "HomeFilled",
    },
    children: [
      {
        path: "home",
        name: "home",
        component: HomeView,
        meta: {
          title: "教学计划",
          hidden: false,
          icon: "Calendar",
        },
      },
    ],
  },
  {
    path: "/teach",
    name: "teach",
    component: Layout,
    redirect: "/teach/course",
    meta: {
      title: "教学安排",
      icon: "Notebook",
    },
    children: [
      {
        name: "course",
        path: "course",
        component: () => import("@/views/teach/CourseView.vue"),
        meta: {
          title: "班级管理",
          icon: "School",
        },
      },
      {
        name: "point",
        path: "point",
        component: () => import("@/views/teach/PointView.vue"),
        meta: {
          title: "创建知识点",
          icon: "Orange",
        },
      },
      {
        name: "pointRelation",
        path: "pointRelation",
        component: () => import("@/views/teach/PointRelation.vue"),
        meta: {
          hidden: true,
          title: "知识点相关",
          icon: "Grape",
        },
        props(route: any) {
          return route.query;
        },
      },
      {
        name: "question",
        path: "question",
        component: () => import("@/views/teach/QuestionView.vue"),
        meta: {
          title: "习题管理",
          icon: "ForkSpoon",
        },
      },
      {
        name: "mainCourse",
        path: "mainCourse",
        component: () => import("@/views/teach/MainCourse.vue"),
        meta: {
          title: "课程班级管理",
          hidden: true,
          icon: "Message",
        },
        props(route: any) {
          return route.query;
        },
      },
      {
        name: "submission",
        path: "submission",
        component: () => import("@/views/teach/HomeworkDetail.vue"),
        meta: {
          hidden: true,
        },
        props(route: any) {
          return route.query;
        },
      },
    ],
  },
  {
    path: "/more",
    redirect: "/more/achievement",
    component: Layout,
    meta: {
      title: "教学反馈",
      icon: "Message",
    },
    children: [
      {
        path: "achievement",
        component: () => import("@/views/more/AchievementView.vue"),
        meta: {
          title: "教学成果",
          icon: "PieChart",
        },
      },
    ],
  },
  {
    path: "/:pathMatch(.*)*",
    redirect: "/login",
    name: "Any",
    meta: {
      hidden: true,
    },
  },
];

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: constantRoutes,
});

export default router;
